<?php
require_once ("/include/common.inc.php");
//require_once ("/data/common.inc.php");
$dsql = $db = new DedeSql(false);
//登陆
if($_POST['action']=='login'){
    $Login = $dsql->GetOne("Select id,username,password,usertype,url From `#@__user` where `username` = '$_POST[username]'");
    if($Login == null){
        echo '<script>alert(\'Error\'); history.back();</script>';
        exit();
    } else {
        if($Login['password'] !== substr(md5($_POST['password']),5,20))
        {
            echo '<script>alert(\'Error\'); history.back();</script>';
            exit();
        }else{
            $_SESSION['id'] = $Login['id'];
            $_SESSION['username'] = $Login['username'];
            $_SESSION['password'] = $Login['password'];
            $_SESSION['usertype'] = $Login['usertype'];
            $_SESSION['url'] = $Login['url'];
            echo '<script>window.location.href=\'./\';</script>';
            exit;
            
            
        }
    }
}
//


if($_SESSION['id'] == null)
{
//    echo $_SESSION['id'];
    header("Location:login.html");
    exit();
}
if($_SESSION['usertype'] <10){
    echo '<script>window.location.href=\'./we/\';</script>';
    exit;
}
if(isset($_GET[logout])){
    session_unset();
    echo '<script>window.location.href=\'./\';</script>';
    exit;
}

include('themes/index.php');
?>